import React from "react";
import {Form, Input} from "antd";
import Config from "@/config";

const GameTypeForm = (props) => {
    let that = props.that;

    function handleChangeVal(key, e) {
        let forD = that.state.formData;
        forD[key] = e.target.value;
        that.setState({
            formData: forD
        });
    }

    // function handleRemoveFile(file) {
    //     return new Promise((resolve, reject) => {
    //         systemDeleteFile({path: file.})
    //             .then(res => {
    //                 resolve(res.success);
    //             })
    //     }).then(r => {
    //         if (r) {
    //             const removed = that.state.fileItems.filter(item => item.uid !== file.uid);
    //             that.setState({
    //                 fileItems: removed
    //             })
    //         }
    //     });
    // }

    return (
        <>
            <Form.Item label={"中文名称"}
                       name={'chineseName'}
                       rules={[{required: true, message: '中文名称不能为空！'}]}
            >
                <Input onChange={(e) => handleChangeVal('chineseName', e)}
                       value={that.state.formData.chineseName}
                       maxLength={200}
                       allowClear/>
            </Form.Item>
            <Form.Item label={"English"}
                       name={'englishName'}
                       rules={[{required: true, message: '英文名称不能为空！'}]}
            >
                <Input onChange={(e) => handleChangeVal('englishName', e)}
                       value={that.state.formData.englishName}
                       maxLength={200}
                       allowClear/>
            </Form.Item>
            <Form.Item label={"描述"}
                       name={'desc'}
                       rules={[{required: true, message: '描述不能为空！'}]}
            >
                <Input.TextArea value={that.state.formData.desc}
                                onChange={(e) => handleChangeVal('desc', e)}
                                rows={10}
                                maxLength={1000} showCount allowClear
                />
            </Form.Item>
            <Form.Item label={"图标类型"}
                       name={'logoType'}
                       rules={[{required: true, message: '图标类型不能为空！'}]}
            >
                <Input value={that.state.formData.logoType}
                       onChange={(e) => handleChangeVal('logoType', e)}
                       maxLength={1000}
                       allowClear
                       addonAfter={<Config.IconFont type={that.state.formData.logoType}/>}
                />
            </Form.Item>

            {/*<Form.Item label={"图片"}*/}
            {/*           name={'image'}*/}
            {/*           rules={[{required: true, message: '图片不能为空！'}]}*/}
            {/*>*/}
            {/*    <Upload*/}
            {/*        fileList={that.state.fileItems}*/}
            {/*        listType={'picture'}*/}
            {/*        maxCount={1}*/}
            {/*        accept=".png, .jpg, .jpeg, .bmp, .svg"*/}
            {/*        customRequest={(options) => commonUpload(that, options)}*/}
            {/*        onRemove={(file) => handleRemoveFile(file)}*/}
            {/*    >*/}
            {/*        <Button icon={<UploadOutlined/>}>Upload</Button>*/}
            {/*    </Upload>*/}
            {/*</Form.Item>*/}
        </>
    )
}
export default GameTypeForm;
